<template>
  <div>
    <header>
      <TopNav :title="$route.meta.title"></TopNav>
    </header>
    <main>
      <van-cell-group>
        <van-field v-model="user.nickName" label="昵称" />
        <van-field v-model="user.introduceSign" label="个性签名" />
        <van-field v-model="password" type="password" label="修改密码" />
      </van-cell-group>
      <div class="btn">
        <van-button
          type="primary"
          style="width: 100%"
          color="#1BAEAE"
          @click="Update"
          >保存</van-button
        >
        <van-button
          type="primary"
          style="width: 100%; margin-top: 0.4rem"
          color="#1BAEAE"
          >退出登录</van-button
        >
      </div>
    </main>
  </div>
</template>

<script>
import { userIDCard, userUpdate } from "@/api/index";
import TopNav from "@/components/topNav.vue";
export default {
  name: "userLoginNum",
  data() {
    return {
      user: {},
      password: "",
    };
  },
  created() {
    userIDCard().then((data) => {
      this.user = data.data;
    });
  },
  methods: {
    Update() {
      userUpdate(this.user.introduceSign,this.user.nickName, this.password,).then((data)=>{
        if (data.resultCode===200) {
            this.$toast.success(data.message)
            this.password=''
        }
      })
    },
  },
  components: { TopNav },
};
</script>
<style scoped lang="less">
main {
  margin-top: 1.2rem;
  .btn {
    width: 90%;
    margin: 0.2rem auto 0;
  }
}
</style>